package org.opens.hutool.string;

import cn.hutool.core.codec.Base64;
import cn.hutool.core.util.StrUtil;
import org.junit.Test;

public class StrTest2 {

    @Test
    public void test1() {
        String str = "A";
        for (byte aByte : str.getBytes()) {
            System.out.println(aByte);
        }
        String encode = Base64.encode(str.getBytes());
        System.out.println(encode);

        String result = Base64.decodeStr(encode);
        System.out.println(result);
    }

    @Test
    public void test2() {
        String str = "/data/java/ring_voice/87214497_c0357016-b6a7-4608-b09f-be9e5d4b7638.wav";
        System.out.println(StrUtil.endWith(str, ".wav"));
        System.out.println(StrUtil.startWith(str, "/"));
    }

    @Test
    public void test3() {
        String str = "/data/java/ring_voice/87214497_c0357016-b6a7-4608-b09f-be9e5d4b7638.wav";
        System.out.println(str.substring(str.lastIndexOf('/'), str.length()));
    }

    @Test
    public void test4() {
        String quetsion = "";
        quetsion = StrUtil.addPrefixIfNot(quetsion, "%");
        quetsion = StrUtil.addSuffixIfNot(quetsion, "%");
        System.out.println(quetsion);
    }


    @Test
    public void testFormat() {
        String format = StrUtil.format("str1 {}, str2 {}", "s1", "s2");
        System.out.println(format);

        String format1 = String.format("str1: %s, str2: %s", "s1", "s2");
        System.out.println(format1);

        int a = 9;
        System.out.println(~121323239);
        System.out.println(Integer.toHexString(~393215));
    }

}
